package com.xbp.examsystem.exception;

import com.xbp.examsystem.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    public Result doResolveException(Exception e){
        e.printStackTrace();
        return Result.error(e.getMessage());
    }

    @ExceptionHandler(value = ExamException.class)
    public Result doResolveExamException(ExamException e){
        e.printStackTrace();
        return Result.error(e.getCode(), e.getMsg());
    }
}
